package com.hualan.zhsq.service.impl.property;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hualan.zhsq.entity.property.UrgencyLevel;
import com.hualan.zhsq.mapper.property.UrgencyLevelMapper;
import com.hualan.zhsq.service.property.UrgencyLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName UrgencyLevelServiceImpl
 * @Description 紧急程度serviceImpl
 * @Author ZheRan
 * @Date 2025年08月04日 下午8:20
 * @Version 1.0
 */
@Service("UrgencyLevelService")
public class UrgencyLevelServiceImpl  implements UrgencyLevelService {
    @Autowired
    private UrgencyLevelMapper urgencyLevelMapper;
    @Override
    public int add(UrgencyLevel entity) {
        return urgencyLevelMapper.insert(entity);
    }

    @Override
    public int edit(UrgencyLevel entity) {
        return urgencyLevelMapper.updateById(entity);
    }

    @Override
    public int remove(Integer id) {
        return urgencyLevelMapper.deleteById(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return urgencyLevelMapper.deleteBatchIds(List.of(ids));
    }

    @Override
    public List<UrgencyLevel> find() {
        return urgencyLevelMapper.selectList(null);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, UrgencyLevel entity) {
        Page<UrgencyLevel> page = new Page<>(pageNum, pageSize);
        Page<UrgencyLevel> urgencyLevelPage = urgencyLevelMapper.selectPage(page, null);
        Map<String, Object> map = new HashMap<>();
        map.put("total", urgencyLevelPage.getTotal());
        map.put("list", urgencyLevelPage.getRecords());
        map.put("size", urgencyLevelPage.getSize());
        return map;
    }

    @Override
    public UrgencyLevel findById(Integer id) {
        return urgencyLevelMapper.selectById(id);
    }
}
